package com.woniuxy.credit_loans.staff_dong.service.impl;

import com.woniuxy.credit_loans.entity.SysRole;
import com.woniuxy.credit_loans.mapper.SysRoleMapper;
import com.woniuxy.credit_loans.staff_dong.dto.RoleDto;
import com.woniuxy.credit_loans.staff_dong.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private SysRoleMapper roleMapper;
    @Override
    public List<SysRole> selAll() {
        return roleMapper.selAll();
    }

    @Override
    public List<Integer> selCheck(Integer empId) {
        return roleMapper.selCheck(empId);
    }

    @Override
    @Transactional
    public int insertRole(RoleDto roleDto) {
        if (roleDto.getRoleIds() != null) {
            roleMapper.deleteByEmpId(roleDto.getEmpId());
        }
        roleMapper.insertRole(roleDto);
        return 0;
    }
}
